package cn.sdhuijin.healthexam.activity;

import android.content.Intent;
import android.os.Bundle;
import android.view.View;
import android.view.View.OnClickListener;
import cn.sdhuijin.healthexam.ExitApplication;
import cn.sdhuijin.healthexam.R;
import cn.sdhuijin.healthexam.control.AbstractControlActivity;
import cn.sdhuijin.healthexam.util.Constants;

/**
 * 健康体检录入-第二页
 * 
 * @author houyuchun
 * 
 */
public class HealthExamEleventhActivity extends AbstractControlActivity
		implements OnClickListener {

	private String createDate;

	@Override
	protected void onCreate(Bundle savedInstanceState) {
		// TODO Auto-generated method stub
		super.onCreate(savedInstanceState);
		setContentView(R.layout.activity_health_exam_eleventh);
		ExitApplication.getInstance().addActivity(this);

		Intent intent = getIntent();
		Bundle bundle = intent.getBundleExtra("bundle");
		if (bundle != null) {
			createDate = bundle.getString("createDate");
		}
		setCurrentEditUserName(createDate);

		addEditTextView(R.id.edt_yaowumingcheng1, "药物名称1");
		addEditTextView(R.id.edt_yongfa1, "用法1");
		addEditTextView(R.id.edt_yongliang1, "用量1");
		addEditTextView(R.id.edt_yongyaoshijian1, "用药时间1");
		addEditTextView(R.id.edt_fuyaoyicongxing1, "服药依从性1");

		addEditTextView(R.id.edt_yaowumingcheng2, "药物名称2");
		addEditTextView(R.id.edt_yongfa2, "用法2");
		addEditTextView(R.id.edt_yongliang2, "用量2");
		addEditTextView(R.id.edt_yongyaoshijian2, "用药时间2");
		addEditTextView(R.id.edt_fuyaoyicongxing2, "服药依从性2");

		addEditTextView(R.id.edt_yaowumingcheng3, "药物名称3");
		addEditTextView(R.id.edt_yongfa3, "用法3");
		addEditTextView(R.id.edt_yongliang3, "用量3");
		addEditTextView(R.id.edt_yongyaoshijian3, "用药时间3");
		addEditTextView(R.id.edt_fuyaoyicongxing3, "服药依从性3");

		addEditTextView(R.id.edt_yaowumingcheng4, "药物名称4");
		addEditTextView(R.id.edt_yongfa4, "用法4");
		addEditTextView(R.id.edt_yongliang4, "用量4");
		addEditTextView(R.id.edt_yongyaoshijian4, "用药时间4");
		addEditTextView(R.id.edt_fuyaoyicongxing4, "服药依从性4");

		addEditTextView(R.id.edt_yaowumingcheng5, "药物名称5");
		addEditTextView(R.id.edt_yongfa5, "用法5");
		addEditTextView(R.id.edt_yongliang5, "用量5");
		addEditTextView(R.id.edt_yongyaoshijian5, "用药时间5");
		addEditTextView(R.id.edt_fuyaoyicongxing5, "服药依从性5");

		addEditTextView(R.id.edt_yaowumingcheng6, "药物名称6");
		addEditTextView(R.id.edt_yongfa6, "用法6");
		addEditTextView(R.id.edt_yongliang6, "用量6");
		addEditTextView(R.id.edt_yongyaoshijian6, "用药时间6");
		addEditTextView(R.id.edt_fuyaoyicongxing6, "服药依从性6");

		// Properties文件路径
		controlManager.setPropertiesPath(Constants.PROPERTIES_PATH + createDate
				+ ".txt");
		controlManager.toControl();

		setEditTextListener(R.id.edt_yongyaoshijian1);
		setEditTextListener(R.id.edt_yongyaoshijian2);
		setEditTextListener(R.id.edt_yongyaoshijian2);
		setEditTextListener(R.id.edt_yongyaoshijian4);
		setEditTextListener(R.id.edt_yongyaoshijian5);
		setEditTextListener(R.id.edt_yongyaoshijian6);

		this.setButtonListener(this, R.id.btn_next, R.id.btn_previous);
	}

	/**
	 * 按钮点击处理事件
	 */
	@Override
	public void onClick(View arg0) {
		Intent intent = new Intent();
		Bundle bundle = new Bundle();
		// 获取点击按钮
		int id = (Integer) arg0.getId();
		switch (id) {
		case R.id.btn_previous:
			controlManager.toProperties();
			bundle.putString("createDate", createDate);
			// 创建日期
			intent.putExtra("bundle", bundle);
			// 前一页按钮
			intent.setClass(this, HealthExamTenthActivity.class);
			startActivity(intent);
			this.finish();
			break;
		case R.id.btn_next:
			controlManager.toProperties();
			bundle.putString("createDate", createDate);
			// 创建日期
			intent.putExtra("bundle", bundle);
			intent.setClass(this, HealthExamTwelvthActivity.class);
			startActivity(intent);
			this.finish();
			break;
		default:
			break;
		}
	}

}
